# -*- coding: utf-8 -*-
"""
@Time: 2022/7/15 10:35
@Author: jins
@File: table_device_20220715.py
@Introduction: 向221数据库的device表中插入数据，一共3万终端，每个终端下挂10各监测点，共30万监测点
"""

from common.mysqlDataOperate import OperateMysql


def insert():
    device_id = 100000001
    op = OperateMysql(version='dxy')
    for i in range(202300001, 202300001+30000):
        device_id_temp = device_id
        for j in range(0, 11):
            if j == 0:
                parent_device_id = '-1'
                root_device_id = '-1'
                device_code = str(i)
                node_type = 'gateway'
            else:
                parent_device_id = str(device_id_temp)
                root_device_id = str(device_id_temp)
                device_code = str(i) + str(j)
                node_type = 'monitor'
            device_name = 'device' + device_code
            sql = f"""INSERT INTO device_center.device
VALUES
	(
		'{device_id}',
		'{parent_device_id}',
		'{root_device_id}',
		'1',
		'{device_code}',
		'bar_code',
		'{node_type}',
		'{device_name}',
		'device_type',
		0,
		'short_name',
		'test',
		1,
		'position',
		'mi15',
		'324090528',
		'1',
		'es',
		'1',
		'config_info',
		0,
		'20221031电信云测试',
		'jins',
		'2022-10-31 00:00:00',
		'jins',
	    '2022-10-31 00:00:00',
	    0)
"""
            op.batch_excute(sql)
            device_id += 1
        op.commit()
    op.close()


if __name__ == '__main__':
    insert()
